package com.inforeach.util.string;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class SpecialStringTransformer_utest
{
    IStringTransformer sut_;

    @Before
    public void setUp()
    {
        sut_ = new SpecialStringTransformer();
    }

    void checkSame(String str)
    {
        Assert.assertSame("forward", str, sut_.forward(str));
        Assert.assertSame("reverse", str, sut_.reverse(str));
    }

    void check(String str, String fwd)
    {
        Assert.assertEquals("forward", fwd, sut_.forward(str));
        Assert.assertEquals("reverse", str, sut_.reverse(fwd));
    }

    @Test
    public void testSame()
    {
        checkSame("abc");
    }

    @Test
    public void testNull()
    {
        check(null, "");
    }

    @Test
    public void testEmpty()
    {
        check("", "_");
    }

    @Test
    public void testLongSpecial()
    {
        String S = "_____";
        check(S, S + "_");
    }

}
